package com.ftg.learn.controller;

import com.ftg.learn.pojo.Pingce;
import com.ftg.learn.service.PingceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@CrossOrigin
@RequestMapping("/pingce")
public class PingceController {
    @Autowired
    PingceService ps;
    //查询全部
    @GetMapping("/show")
    public Map<String,Object> showall(int page,int limit){
        Map<String,Object> map = new HashMap<>();
        List<Pingce> list = ps.showall(page,limit);
        map.put("data",list);
        map.put("code",0);
        map.put("count", ps.getcount());
        map.put("msg","到哪里");
        return map;
    }
    //查一
    @PutMapping("/findone")
    public List<Pingce> findone(String pingce_id,String pingce_bt){
        return ps.findone(pingce_id,pingce_bt);
    }
    //添加
    @PutMapping("/add")
    public int add(Pingce pingce){
        return ps.add(pingce);
    }
    //删除
   @DeleteMapping("/delete/{pingce_id}")
    public int delete(@PathVariable String pingce_id){
        return ps.delete(pingce_id);
   }
   //修改
    @PostMapping("/update")
    public int update(Pingce pingce){
        return ps.update(pingce);
    }
}












